<template>
	<view class="wrap">
		<view class="topBc"></view>
		<view class="content formWrap">
			<view class="title" style="margin-top: 0;">外商投资经营情况</view>
			<u-form :model="formData" ref="uForm" :rules="rules">
				<u-form-item v-if="formKeys.opcost" label="营业成本" prop="opcost" required label-width="auto" borderBottom>
					<u-input v-model="formData.opcost" placeholder="请输入" border="none" inputAlign="right">
						<view
							slot="prefix" style="transform: translateX(-12rpx);"
							@click="$util.showModal({content:'报告年度企业(机构)及其分支机构的主营业务成本与其他业务成本支出。'})"
						>
							<u-icon name="question-circle" :color="bgColor" size="34rpx"></u-icon>
						</view>
						<view class="units_suffix" slot="suffix">
							<text><text class="units_suffix_colorRed">万</text>(元)</text>
						</view>					</u-input>
				</u-form-item>
				<u-form-item v-if="formKeys.opexp" label="营业费用" prop="opexp" required label-width="auto" borderBottom>
					<u-input v-model="formData.opexp" placeholder="请输入" border="none" inputAlign="right">
						<view
							slot="prefix" style="transform: translateX(-12rpx);"
							@click="$util.showModal({content:'报告年度企业(机构) 及其分支机构在经营过程中发生的费用。'})"
						>
							<u-icon name="question-circle" :color="bgColor" size="34rpx"></u-icon>
						</view>
						<view class="units_suffix" slot="suffix">
							<text><text class="units_suffix_colorRed">万</text>(元)</text>
						</view>					</u-input>
				</u-form-item>
				<u-form-item v-if="formKeys.rdspending" label="研发投入" prop="rdspending" required label-width="auto" borderBottom>
					<u-input v-model="formData.rdspending" placeholder="请输入" border="none" inputAlign="right">
						<view
							slot="prefix" style="transform: translateX(-12rpx);"
							@click="$util.showModal({content:'报告年度企业(机构)及其分支机构研究与开发过程中发生的各项支出。'})"
						>
							<u-icon name="question-circle" :color="bgColor" size="34rpx"></u-icon>
						</view>
						<view class="units_suffix" slot="suffix">
							<text><text class="units_suffix_colorRed">万</text>(元)</text>
						</view>					</u-input>
				</u-form-item>
				
				<view class="title" style="display: flex; align-items: center;">
					<view style="margin-right: 12rpx;">纳税总额</view>
					<u-icon name="question-circle" :color="bgColor" size="34rpx"
						@click="$util.showModal({content:'报告年度企业(机构)及其分支机构实际缴纳的税收总额，包括为员工代扣代缴的个人所得税。'})"
					></u-icon>
				</view>
				<u-form-item v-if="formKeys.vat" label="增值税" prop="vat" required label-width="auto" borderBottom>
					<u-input v-model="formData.vat" placeholder="请输入" border="none" inputAlign="right">
						<view class="units_suffix" slot="suffix">
							<text><text class="units_suffix_colorRed">万</text>(元)</text>
						</view>					</u-input>
				</u-form-item>
				<u-form-item v-if="formKeys.busitax" label="营业税" prop="busitax" required label-width="auto" borderBottom>
					<u-input v-model="formData.busitax" placeholder="请输入" border="none" inputAlign="right">
						<view class="units_suffix" slot="suffix">
							<text><text class="units_suffix_colorRed">万</text>(元)</text>
						</view>					</u-input>
				</u-form-item>
				<u-form-item v-if="formKeys.consumtax" label="消费税" prop="consumtax" required label-width="auto" borderBottom>
					<u-input v-model="formData.consumtax" placeholder="请输入" border="none" inputAlign="right">
						<view class="units_suffix" slot="suffix">
							<text><text class="units_suffix_colorRed">万</text>(元)</text>
						</view>					</u-input>
				</u-form-item>
				<u-form-item v-if="formKeys.entincometax" label="企业所得税" prop="entincometax" required label-width="auto" borderBottom>
					<u-input v-model="formData.entincometax" placeholder="请输入" border="none" inputAlign="right">
						<view class="units_suffix" slot="suffix">
							<text><text class="units_suffix_colorRed">万</text>(元)</text>
						</view>					</u-input>
				</u-form-item>
				<u-form-item v-if="formKeys.indincometax" label="个人所得税" prop="indincometax" required label-width="auto" borderBottom>
					<u-input v-model="formData.indincometax" placeholder="请输入" border="none" inputAlign="right">
						<view class="units_suffix" slot="suffix">
							<text><text class="units_suffix_colorRed">万</text>(元)</text>
						</view>					</u-input>
				</u-form-item>
				<u-form-item v-if="formKeys.tariffs" label="关税" prop="tariffs" required label-width="auto" borderBottom>
					<u-input v-model="formData.tariffs" placeholder="请输入" border="none" inputAlign="right">
						<view class="units_suffix" slot="suffix">
							<text><text class="units_suffix_colorRed">万</text>(元)</text>
						</view>					</u-input>
				</u-form-item>
				
				<view class="title" style="display: flex; align-items: center;">
					<view style="margin-right: 12rpx;">净利润</view>
					<u-icon name="question-circle" :color="bgColor" size="34rpx"
						@click="$util.showModal({content:`企业（机构）及其分支机构在报告年度实现的净利润，亏损用 “-” 表示。
						按企业当年财务会计报告中“利润表”所披露的“净利润”科目发生额填写。`})"
					></u-icon>
				</view>
				<u-form-item v-if="formKeys.allotforprofits" label="分配外方股东的利润" prop="allotforprofits" required label-width="auto" borderBottom>
					<u-input v-model="formData.allotforprofits" placeholder="请输入" border="none" inputAlign="right">
						<view
							slot="prefix" style="transform: translateX(-12rpx);"
							@click="$util.showModal({content:'报告年度实际分配外方股东的利润。'})"
						>
							<u-icon name="question-circle" :color="bgColor" size="34rpx"></u-icon>
						</view>
						<view class="units_suffix" slot="suffix">
							<text><text class="units_suffix_colorRed">万</text>(元)</text>
						</view>					</u-input>
				</u-form-item>
				<u-form-item v-if="formKeys.remitforprofits" label="汇往外方股东的利润" prop="remitforprofits" required label-width="auto" borderBottom>
					<u-input v-model="formData.remitforprofits" placeholder="请输入" border="none" inputAlign="right">
						<view
							slot="prefix" style="transform: translateX(-12rpx);"
							@click="$util.showModal({content:'报告年度实际汇往外方股东的利润。'})"
						>
							<u-icon name="question-circle" :color="bgColor" size="34rpx"></u-icon>
						</view>
						<view class="units_suffix" slot="suffix">
							<text><text class="units_suffix_colorRed">万</text>(元)</text>
						</view>					</u-input>
				</u-form-item>
				<u-form-item v-if="formKeys.fornetprofit" label="外方股东享有的净利润" prop="fornetprofit" required label-width="auto" borderBottom>
					<u-input v-model="formData.fornetprofit" placeholder="请输入" border="none" inputAlign="right">
						<view
							slot="prefix" style="transform: translateX(-12rpx);"
							@click="$util.showModal({content:`报告年度净利润中归厘于外方股东的部分，按外方股东股权比例或约定比例
							(符合相关法律法规规定) 乘以企业财务报表中的净利润填写`})"
						>
							<u-icon name="question-circle" :color="bgColor" size="34rpx"></u-icon>
						</view>
						<view class="units_suffix" slot="suffix">
							<text><text class="units_suffix_colorRed">万</text>(元)</text>
						</view>					</u-input>
				</u-form-item>
				
				<view class="title" style="display: flex; align-items: center;">
					<view style="margin-right: 12rpx;">外方股东利润转投资</view>
					<u-icon name="question-circle" :color="bgColor" size="34rpx"
						@click="$util.showModal({content:`报告年度外方股东利润转投资金额，包括转增本企业(机构)注册资本和转投其他企业(机构) 注册资本。`})"
					></u-icon>
				</view>
				<u-form-item v-if="formKeys.forproftoinv" label="外方股东利润转投资" prop="forproftoinv" required label-width="auto" borderBottom>
					<u-input v-model="formData.forproftoinv" placeholder="请输入" border="none" inputAlign="right">
						<view class="units_suffix" slot="suffix">
							<text><text class="units_suffix_colorRed">万</text>(元)</text>
						</view>					</u-input>
				</u-form-item>
				<u-form-item v-if="formKeys.increaseregcap" label="转增本企业(机构)注册资本" prop="increaseregcap" required label-width="auto" borderBottom>
					<u-input v-model="formData.increaseregcap" placeholder="请输入" border="none" inputAlign="right">
						<view class="units_suffix" slot="suffix">
							<text><text class="units_suffix_colorRed">万</text>(元)</text>
						</view>					</u-input>
				</u-form-item>
				<u-form-item v-if="formKeys.transothent" label="转投其他企业(机构)注册资本" prop="transothent" required label-width="auto" borderBottom>
					<u-input v-model="formData.transothent" placeholder="请输入" border="none" inputAlign="right">
						<view class="units_suffix" slot="suffix">
							<text><text class="units_suffix_colorRed">万</text>(元)</text>
						</view>					</u-input>
				</u-form-item>
				
			</u-form>
			
		</view>
		<view class="submitBtn_bc"></view>
		<view class="submitBtn_ubtn">
			<u-button :disabled="!$util.submitState(year,state)" @click="submit()">提交</u-button>
		</view>
	</view>
</template>

<script>
export default {
	data(){
		return{
			minFormName: 'operateinfo', //小表单类型名
			regnoInfo: this.$store.state.regnoInfo,
			year: '',
			state: '',
			bgColor: this.$config.bgColor,
			
			formData: {
				opcost: '',
				opexp: '',
				rdspending: '',
				vat: '',
				busitax: '',
				
				consumtax: '',
				entincometax: '',
				indincometax: '',
				tariffs: '',
				allotforprofits: '',
				
				remitforprofits: '',
				fornetprofit: '',
				forproftoinv: '',
				increaseregcap: '',
				transothent: '',
			},
			rules: {},
			rulesAll: {
				opcost: this.$typeData.ruleData.moneyRule,
				opexp: this.$typeData.ruleData.moneyRule,
				rdspending: this.$typeData.ruleData.moneyRule,
				vat: this.$typeData.ruleData.moneyRule,
				busitax: this.$typeData.ruleData.moneyRule,
				
				consumtax: this.$typeData.ruleData.moneyRule,
				entincometax: this.$typeData.ruleData.moneyRule,
				indincometax: this.$typeData.ruleData.moneyRule,
				tariffs: this.$typeData.ruleData.moneyRule,
				allotforprofits: this.$typeData.ruleData.moneyRule,
				
				remitforprofits: this.$typeData.ruleData.moneyRule,
				fornetprofit: this.$typeData.ruleData.moneyRule,
				forproftoinv: this.$typeData.ruleData.moneyRule,
				increaseregcap: this.$typeData.ruleData.moneyRule,
				transothent: this.$typeData.ruleData.moneyRule,
			},
			formKeys: {},
		}
	},
	onLoad(option) {
		this.year = option.year;
		this.state = option.state;
		this.getFormKey();
		this.getFormData();
	},
	onReady() {
		this.$refs.uForm.setRules(this.rules)
	},
	methods:{
		// 获取小表单数据
		getFormData(){
			let url = this.$typeData.minFormUrl.get(this.minFormName);
			if(!url){
				uni.showModal({
					title: '暂无接口'
				})
				return;
			}
			this.$http.sendRequest({
				url: url,
				data: {
					regno: this.regnoInfo.regno,
					ancheyear: this.year
				}
			})
			.then(res=>{
				console.log('接口返回',res.data);
				let data = res.data;				let keys = Object.keys(this.formKeys);				keys.forEach(item=>{					this.formData[item] = data[item];				})
				console.log(789789,this.formData);
			})
			.catch(err=>{})
		},
		//获取小表单拥有字段
		getFormKey(){
			let formKeys = this.$util.getFormKeys(this.minFormName,this.regnoInfo.enttype);
			this.formKeys = formKeys;
			let keys = Object.keys(formKeys);
			keys.forEach(item=>{
				this.rules[item] = this.rulesAll[item];
			})
		},
		submit(){
			this.$refs.uForm.validate().then(res => {
				this.saveBtn();
			}).catch(errors => {
				this.$util.showToast({title:'请完善信息'})
			})
		},
		saveBtn(){
			let data = {
				regno: this.regnoInfo.regno,
				ancheyear: this.year,
			}
			data = this.$util.setSaveFormData(this.formKeys,data,this.formData);
			this.$http.sendRequest({
				url: '/annual/report/ws-baseinfo/update-wsoperateinfo',
				method: 'PUT',
				data: data
			})
			.then(res=>{
				this.setRecord();
			})
			.catch(err=>{})
		},
		
		
		
		
		
		//存一下记录
		setRecord(){
			let fillingItem = this.$minFormType.get(this.minFormName);
			this.$http.sendRequest({
				url: '/annual/report/record',
				method: 'POST',
				data: {
					regno: this.regnoInfo.regno,
					year: this.year,
					fillingItem: fillingItem,
					isImp: '0',
				},
				hideLoad: true,
			})
			.then(res=>{
				uni.navigateBack();
			})
			.catch(err=>{})
		},
		goPage(path){
			uni.navigateTo({
				url: path
			})
		},
	}
}
</script>

<style lang="less" scoped>
.wrap{
	width: 100vw;
	min-height: 100vh;
	padding-top: 16rpx;
	box-sizing: border-box;
	position: relative;
	background-color: #FFF;
	
	.topBc{
		height: 10rpx;
		background-color: #F5F6F8;
	}
}

.content{
	padding: 30rpx 36rpx;
	background-color: #FFF;
	
	.title{
		color: #E4B269;
		font-size: 36rpx;
		font-weight: bold;
		border-left: 8rpx solid #E4B269;
		line-height: 40rpx;
		padding-left: 16rpx;
		margin-bottom: 30rpx;
		margin-top: 30rpx;
	}
	
	
}
</style>